<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据库管理</title>
<script type="text/javascript" src="/j-tool/jquery.js"></script>
<link href='/public/css/admins.css' rel='stylesheet' type='text/css'/>
<body>
	<div class='bread'>消息管理</div>
	<div class="manageBox">
		<div class="formBox">
			<form method="post" name="psource" action="" onsubmit="return false;"> 
				<table class="searchBox">
					<tr>
						<td>发件人：</td><td><input type="text" name="name" class="input-text"/></td>
					</tr>
					<tr>
						<td>电子邮件：</td><td><input type="text" name="email" class="input-text"/></td>
					</tr>
					<tr>
						<td>时间段：</td>
						<td><input type="text" name="stime" class="input-text" value="<!--{$tomorrow|date_format:'%Y-%m-%d'}-->" style="width:81px;text-align:center;"/>&nbsp;--&nbsp;<input type="text" name="etime" class="input-text" value="<!--{$lastmonth|date_format:'%Y-%m-%d'}-->" style="width:82px;text-align:center;"/></td>
					</tr>
					<tr>
						<td></td><td><input type="submit" value="查询" class="butt" onclick="msearch();"/>&nbsp;&nbsp;&nbsp;&nbsp;标记为：&nbsp;&nbsp;<a href="JavaScript:;" onclick="dealWith('read')">已读</a>&nbsp;|&nbsp;<a href="JavaScript:;" onclick="dealWith('dele')">删除</a></td>
					</tr>
				</table>
			</form>
			<div class="clear"></div>
		</div>
		<div class="infolist">
			<ul><li class="w5"><a href="javascript:;" onclick="choseAll();">全选</a></li><li class="w10">发件人</li><li class="w15">电子邮箱</li><li class="w40">消息</li><li class="w15">时间</li><li>状态</li></ul>
			<div class="result">
				<!--{foreach from=$list item=val}-->
				<ul>
					<li class="w5"><input type="checkbox" name="chose[<!--{$val.id}-->]" value="<!--{$val.id}-->"/></li>
					<li class="w10"><!--{$val.name}--></li>
					<li class="w15"><!--{$val.email}--></li>
					<li class="w40"><!--{$val.message}--></li>
					<li class="w15"><!--{$val.addtime}--></li>
					<li><!--{if $val.step eq 0}--><font color='red'>未读</font><!--{else}--><font color='gray'>已读</font><!--{/if}--></li>
				</ul>
				<!--{/foreach}-->
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="/j-tool/admins.js"></script>
<script type="text/javascript">
	function dealWith(does)
	{	
		$.ajax({
		   type: "POST",
		   url: "admins_ajax.php",
		   data: 'action=msg_'+does+'&'+$("input:checked").serialize(),
		   success: function(msg){
				msg == 'OK'?location.reload():alert(msg);;				
		   }
		});
	}
	function msearch()
	{
		$.ajax({
		   type: "POST",
		   url: "admins_ajax.php",
		   data: 'action=message&'+$("form").serialize(),
		   success: function(msg){
				if(msg !='null')
				{
					var data = $.parseJSON(msg),html='';
					for(var i=0;i<data.length;i++)
					{
						html += '<ul><li class="w5"><input type="checkbox" name="chose['+data[i].id+']" value="'+data[i].id+'"/></li><li class="w10">'+data[i].name+'</li><li class="w15">'+data[i].email+'</li><li class="w40">'+data[i].message+'</li><li class="w15">'+data[i].addtime+'</li><li>'+(data[i].step==0?"<font color=red>未读</font>":"<font color=gray>已读</font>")+'</li></ul>';
					}
					$('.result').html(html);
				}else{
					alert('没有找到相关数据');
				}			
		   }
		});
	}
</script>
</html>